{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:50.368907Z",
     "start_time": "2019-05-17T11:58:49.640841Z"
    }
   },
   "outputs": [],
   "source": [
    "import requests\n",
    "from lxml import etree\n",
    "import pandas as pd\n",
    "import re\n",
    "import numpy as np\n",
    "import math"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#首先定义全局变量，这些全局变量主要包括股票代码和所需年份"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:50.377891Z",
     "start_time": "2019-05-17T11:58:50.371897Z"
    }
   },
   "outputs": [],
   "source": [
    "stockid='600519'\n",
    "year=2018\n",
    "Tax=0.25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:50.403894Z",
     "start_time": "2019-05-17T11:58:50.380893Z"
    }
   },
   "outputs": [],
   "source": [
    "#定义一个将千分位分隔符去掉的函数，它需要在爬虫程序中用到\n",
    "def convert(num):\n",
    "    if num=='':\n",
    "        return None\n",
    "    elif num==0:\n",
    "        return 0\n",
    "    else:\n",
    "        return float(re.sub(',','',num))\n",
    "\n",
    "#由于要多次使用此爬虫程序，因此将爬虫程序定义成一个函数对象,函数如下\n",
    "\n",
    "def sheet1(url,xpath1):#参数分别为网址，xpath信息提取路径\n",
    "    header={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0'}\n",
    "    response=requests.get(url,headers=header)#利用requests库，使用get方式获取网页文档\n",
    "    response.encoding='gb2312'#指定解析网页的编码方式，避免网页中文乱码\n",
    "    html=etree.HTML(response.text)\n",
    "    FD_BalanceSheet=html.xpath(xpath1)#获取当前网页下的整个报表数据\n",
    "    Accounts=[]\n",
    "    values=[]\n",
    "    for i in range(2,len(FD_BalanceSheet)):\n",
    "        sheet1=FD_BalanceSheet[i].xpath('./td//text()')\n",
    "        if len(sheet1)==1:\n",
    "            sheet1.insert(1,'')#有部分属于总科目，比如流动资产，非流动资产，为了避免报错，将这类总科目后的数值设为空白\n",
    "        if sheet1[1]=='--':#将原报表中不存在的科目转化为0\n",
    "            sheet1[1]=0\n",
    "        values1=convert(sheet1[1])\n",
    "        Accounts.append(sheet1[0])\n",
    "        values.append(values1)\n",
    "#    vFD_BalanceSheet=pd.DataFrame({'Accounts':Accounts,'values':values})#将结果以Dataframe的方式输出,其中空白部分的数据会被转化成NaN缺失值形式\n",
    "    return Accounts,values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:50.963383Z",
     "start_time": "2019-05-17T11:58:50.408895Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Accounts</th>\n",
       "      <th>2016</th>\n",
       "      <th>2017</th>\n",
       "      <th>2018</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>流动资产</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>货币资金</td>\n",
       "      <td>6685496.21</td>\n",
       "      <td>8786886.99</td>\n",
       "      <td>11207479.14</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>交易性金融资产</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>衍生金融资产</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>应收票据</td>\n",
       "      <td>81762.72</td>\n",
       "      <td>122170.60</td>\n",
       "      <td>56373.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>应收账款</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>预付款项</td>\n",
       "      <td>104610.07</td>\n",
       "      <td>79080.73</td>\n",
       "      <td>118237.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>应收利息</td>\n",
       "      <td>14090.49</td>\n",
       "      <td>24145.86</td>\n",
       "      <td>34388.99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>应收股利</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>其他应收款</td>\n",
       "      <td>7722.76</td>\n",
       "      <td>3132.35</td>\n",
       "      <td>5000.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>买入返售金融资产</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>存货</td>\n",
       "      <td>2062225.18</td>\n",
       "      <td>2205748.14</td>\n",
       "      <td>2350695.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>划分为持有待售的资产</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>一年内到期的非流动资产</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>待摊费用</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>待处理流动资产损益</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>其他流动资产</td>\n",
       "      <td>23147.46</td>\n",
       "      <td>3753.92</td>\n",
       "      <td>14008.43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>流动资产合计</td>\n",
       "      <td>9018054.88</td>\n",
       "      <td>11224918.60</td>\n",
       "      <td>13786183.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>非流动资产</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>发放贷款及垫款</td>\n",
       "      <td>6083.35</td>\n",
       "      <td>3315.00</td>\n",
       "      <td>3607.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>可供出售金融资产</td>\n",
       "      <td>2900.00</td>\n",
       "      <td>2900.00</td>\n",
       "      <td>2900.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>持有至到期投资</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>长期应收款</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>长期股权投资</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>投资性房地产</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>固定资产净额</td>\n",
       "      <td>1445317.74</td>\n",
       "      <td>1524409.66</td>\n",
       "      <td>1524855.66</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>在建工程</td>\n",
       "      <td>274558.00</td>\n",
       "      <td>201640.50</td>\n",
       "      <td>195432.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>工程物资</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>固定资产清理</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>生产性生物资产</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>一年内的递延收益</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>应付短期债券</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>一年内到期的非流动负债</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>其他流动负债</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>流动负债合计</td>\n",
       "      <td>3702042.54</td>\n",
       "      <td>3857491.94</td>\n",
       "      <td>4243818.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>非流动负债</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>长期借款</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>应付债券</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td>长期应付款</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62</th>\n",
       "      <td>长期应付职工薪酬</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>63</th>\n",
       "      <td>专项应付款</td>\n",
       "      <td>1557.00</td>\n",
       "      <td>1557.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>预计非流动负债</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>65</th>\n",
       "      <td>递延所得税负债</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66</th>\n",
       "      <td>长期递延收益</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>67</th>\n",
       "      <td>其他非流动负债</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>68</th>\n",
       "      <td>非流动负债合计</td>\n",
       "      <td>1557.00</td>\n",
       "      <td>1557.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69</th>\n",
       "      <td>负债合计</td>\n",
       "      <td>3703599.54</td>\n",
       "      <td>3859048.94</td>\n",
       "      <td>4243818.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>所有者权益</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71</th>\n",
       "      <td>实收资本(或股本)</td>\n",
       "      <td>125619.78</td>\n",
       "      <td>125619.78</td>\n",
       "      <td>125619.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>资本公积</td>\n",
       "      <td>137496.44</td>\n",
       "      <td>137496.44</td>\n",
       "      <td>137496.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>73</th>\n",
       "      <td>减：库存股</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>其他综合收益</td>\n",
       "      <td>-1124.08</td>\n",
       "      <td>-740.16</td>\n",
       "      <td>-706.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75</th>\n",
       "      <td>专项储备</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>76</th>\n",
       "      <td>盈余公积</td>\n",
       "      <td>713565.00</td>\n",
       "      <td>821559.55</td>\n",
       "      <td>1344422.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>一般风险准备</td>\n",
       "      <td>42075.84</td>\n",
       "      <td>60085.92</td>\n",
       "      <td>78830.26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>未分配利润</td>\n",
       "      <td>6271780.80</td>\n",
       "      <td>8001130.75</td>\n",
       "      <td>9598194.40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>79</th>\n",
       "      <td>归属于母公司股东权益合计</td>\n",
       "      <td>7289413.78</td>\n",
       "      <td>9145152.28</td>\n",
       "      <td>11283856.43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>80</th>\n",
       "      <td>少数股东权益</td>\n",
       "      <td>300440.51</td>\n",
       "      <td>456810.46</td>\n",
       "      <td>456992.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>81</th>\n",
       "      <td>所有者权益(或股东权益)合计</td>\n",
       "      <td>7589854.29</td>\n",
       "      <td>9601962.75</td>\n",
       "      <td>11740848.79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>82</th>\n",
       "      <td>负债和所有者权益(或股东权益)总计</td>\n",
       "      <td>11293453.83</td>\n",
       "      <td>13461011.69</td>\n",
       "      <td>15984667.47</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>83 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             Accounts         2016         2017         2018\n",
       "0                流动资产          NaN          NaN          NaN\n",
       "1                货币资金   6685496.21   8786886.99  11207479.14\n",
       "2             交易性金融资产         0.00         0.00         0.00\n",
       "3              衍生金融资产         0.00         0.00         0.00\n",
       "4                应收票据     81762.72    122170.60     56373.97\n",
       "5                应收账款         0.00         0.00         0.00\n",
       "6                预付款项    104610.07     79080.73    118237.85\n",
       "7                应收利息     14090.49     24145.86     34388.99\n",
       "8                应收股利         0.00         0.00         0.00\n",
       "9               其他应收款      7722.76      3132.35      5000.05\n",
       "10           买入返售金融资产         0.00         0.00         0.00\n",
       "11                 存货   2062225.18   2205748.14   2350695.08\n",
       "12         划分为持有待售的资产         0.00         0.00         0.00\n",
       "13        一年内到期的非流动资产         0.00         0.00         0.00\n",
       "14               待摊费用         0.00         0.00         0.00\n",
       "15          待处理流动资产损益         0.00         0.00         0.00\n",
       "16             其他流动资产     23147.46      3753.92     14008.43\n",
       "17             流动资产合计   9018054.88  11224918.60  13786183.53\n",
       "18              非流动资产          NaN          NaN          NaN\n",
       "19            发放贷款及垫款      6083.35      3315.00      3607.50\n",
       "20           可供出售金融资产      2900.00      2900.00      2900.00\n",
       "21            持有至到期投资         0.00         0.00         0.00\n",
       "22              长期应收款         0.00         0.00         0.00\n",
       "23             长期股权投资         0.00         0.00         0.00\n",
       "24             投资性房地产         0.00         0.00         0.00\n",
       "25             固定资产净额   1445317.74   1524409.66   1524855.66\n",
       "26               在建工程    274558.00    201640.50    195432.30\n",
       "27               工程物资         0.00         0.00         0.00\n",
       "28             固定资产清理         0.00         0.00         0.00\n",
       "29            生产性生物资产         0.00         0.00         0.00\n",
       "..                ...          ...          ...          ...\n",
       "53           一年内的递延收益         0.00         0.00         0.00\n",
       "54             应付短期债券         0.00         0.00         0.00\n",
       "55        一年内到期的非流动负债         0.00         0.00         0.00\n",
       "56             其他流动负债         0.00         0.00         0.00\n",
       "57             流动负债合计   3702042.54   3857491.94   4243818.68\n",
       "58              非流动负债          NaN          NaN          NaN\n",
       "59               长期借款         0.00         0.00         0.00\n",
       "60               应付债券         0.00         0.00         0.00\n",
       "61              长期应付款         0.00         0.00         0.00\n",
       "62           长期应付职工薪酬         0.00         0.00         0.00\n",
       "63              专项应付款      1557.00      1557.00         0.00\n",
       "64            预计非流动负债         0.00         0.00         0.00\n",
       "65            递延所得税负债         0.00         0.00         0.00\n",
       "66             长期递延收益         0.00         0.00         0.00\n",
       "67            其他非流动负债         0.00         0.00         0.00\n",
       "68            非流动负债合计      1557.00      1557.00         0.00\n",
       "69               负债合计   3703599.54   3859048.94   4243818.68\n",
       "70              所有者权益          NaN          NaN          NaN\n",
       "71          实收资本(或股本)    125619.78    125619.78    125619.78\n",
       "72               资本公积    137496.44    137496.44    137496.44\n",
       "73              减：库存股         0.00         0.00         0.00\n",
       "74             其他综合收益     -1124.08      -740.16      -706.57\n",
       "75               专项储备         0.00         0.00         0.00\n",
       "76               盈余公积    713565.00    821559.55   1344422.12\n",
       "77             一般风险准备     42075.84     60085.92     78830.26\n",
       "78              未分配利润   6271780.80   8001130.75   9598194.40\n",
       "79       归属于母公司股东权益合计   7289413.78   9145152.28  11283856.43\n",
       "80             少数股东权益    300440.51    456810.46    456992.36\n",
       "81     所有者权益(或股东权益)合计   7589854.29   9601962.75  11740848.79\n",
       "82  负债和所有者权益(或股东权益)总计  11293453.83  13461011.69  15984667.47\n",
       "\n",
       "[83 rows x 4 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "yearvalues=[]\n",
    "for i in range(year-2,year+1):\n",
    "    capitalurl='http://money.finance.sina.com.cn/corp/go.php/vFD_BalanceSheet/stockid/'+str(stockid)+'/ctrl/'+str(i)+'/displaytype/4.phtml'\n",
    "    capitalxpath1='//*[@id=\"BalanceSheetNewTable0\"]/tbody//tr'\n",
    "    Accounts,years=sheet1(capitalurl,capitalxpath1)#获取近三年的资产负债表表\n",
    "    yearvalues.append(years)\n",
    "data1=pd.DataFrame({'Accounts':Accounts})\n",
    "data1[year-2]=yearvalues[0]\n",
    "data1[year-1]=yearvalues[1]\n",
    "data1[year]=yearvalues[2]\n",
    "data1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:51.392671Z",
     "start_time": "2019-05-17T11:58:50.966382Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Accounts</th>\n",
       "      <th>2016</th>\n",
       "      <th>2017</th>\n",
       "      <th>2018</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>一、营业总收入</td>\n",
       "      <td>4015508.44</td>\n",
       "      <td>6106275.69</td>\n",
       "      <td>7719938.41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>营业收入</td>\n",
       "      <td>3886219.00</td>\n",
       "      <td>5821786.13</td>\n",
       "      <td>7363887.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>二、营业总成本</td>\n",
       "      <td>1588945.92</td>\n",
       "      <td>2212274.93</td>\n",
       "      <td>2586603.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>营业成本</td>\n",
       "      <td>341010.41</td>\n",
       "      <td>594043.64</td>\n",
       "      <td>652292.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>营业税金及附加</td>\n",
       "      <td>650892.63</td>\n",
       "      <td>840421.45</td>\n",
       "      <td>1128892.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>销售费用</td>\n",
       "      <td>168105.20</td>\n",
       "      <td>298606.85</td>\n",
       "      <td>257207.69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>管理费用</td>\n",
       "      <td>418718.98</td>\n",
       "      <td>472054.28</td>\n",
       "      <td>532594.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>财务费用</td>\n",
       "      <td>-3317.52</td>\n",
       "      <td>-5572.23</td>\n",
       "      <td>-352.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>资产减值损失</td>\n",
       "      <td>1232.75</td>\n",
       "      <td>-805.37</td>\n",
       "      <td>128.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>公允价值变动收益</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>投资收益</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>其中:对联营企业和合营企业的投资收益</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>汇兑收益</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>三、营业利润</td>\n",
       "      <td>2426562.52</td>\n",
       "      <td>3894000.75</td>\n",
       "      <td>5134298.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>加:营业外收入</td>\n",
       "      <td>855.39</td>\n",
       "      <td>1220.20</td>\n",
       "      <td>1161.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>减：营业外支出</td>\n",
       "      <td>31629.81</td>\n",
       "      <td>21213.74</td>\n",
       "      <td>52700.38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>其中：非流动资产处置损失</td>\n",
       "      <td>196.10</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>四、利润总额</td>\n",
       "      <td>2395788.10</td>\n",
       "      <td>3874007.21</td>\n",
       "      <td>5082760.34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>减：所得税费用</td>\n",
       "      <td>602723.78</td>\n",
       "      <td>973364.89</td>\n",
       "      <td>1299798.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>五、净利润</td>\n",
       "      <td>1793064.31</td>\n",
       "      <td>2900642.32</td>\n",
       "      <td>3782961.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>归属于母公司所有者的净利润</td>\n",
       "      <td>1671836.27</td>\n",
       "      <td>2707936.03</td>\n",
       "      <td>3520362.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>少数股东损益</td>\n",
       "      <td>121228.04</td>\n",
       "      <td>192706.30</td>\n",
       "      <td>262599.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>六、每股收益</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>基本每股收益(元/股)</td>\n",
       "      <td>13.31</td>\n",
       "      <td>21.56</td>\n",
       "      <td>28.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>稀释每股收益(元/股)</td>\n",
       "      <td>13.31</td>\n",
       "      <td>21.56</td>\n",
       "      <td>28.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>七、其他综合收益</td>\n",
       "      <td>179.32</td>\n",
       "      <td>383.93</td>\n",
       "      <td>33.59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>八、综合收益总额</td>\n",
       "      <td>1793243.63</td>\n",
       "      <td>2901026.25</td>\n",
       "      <td>3782995.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>归属于母公司所有者的综合收益总额</td>\n",
       "      <td>1672015.60</td>\n",
       "      <td>2708319.95</td>\n",
       "      <td>3520396.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>归属于少数股东的综合收益总额</td>\n",
       "      <td>121228.04</td>\n",
       "      <td>192706.30</td>\n",
       "      <td>262599.25</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              Accounts        2016        2017        2018\n",
       "0              一、营业总收入  4015508.44  6106275.69  7719938.41\n",
       "1                 营业收入  3886219.00  5821786.13  7363887.24\n",
       "2              二、营业总成本  1588945.92  2212274.93  2586603.06\n",
       "3                 营业成本   341010.41   594043.64   652292.18\n",
       "4              营业税金及附加   650892.63   840421.45  1128892.68\n",
       "5                 销售费用   168105.20   298606.85   257207.69\n",
       "6                 管理费用   418718.98   472054.28   532594.08\n",
       "7                 财务费用    -3317.52    -5572.23     -352.12\n",
       "8               资产减值损失     1232.75     -805.37      128.97\n",
       "9             公允价值变动收益        0.00        0.00        0.00\n",
       "10                投资收益        0.00        0.00        0.00\n",
       "11  其中:对联营企业和合营企业的投资收益        0.00        0.00        0.00\n",
       "12                汇兑收益        0.00        0.00        0.00\n",
       "13              三、营业利润  2426562.52  3894000.75  5134298.77\n",
       "14             加:营业外收入      855.39     1220.20     1161.95\n",
       "15             减：营业外支出    31629.81    21213.74    52700.38\n",
       "16        其中：非流动资产处置损失      196.10        0.00        0.00\n",
       "17              四、利润总额  2395788.10  3874007.21  5082760.34\n",
       "18             减：所得税费用   602723.78   973364.89  1299798.57\n",
       "19               五、净利润  1793064.31  2900642.32  3782961.78\n",
       "20       归属于母公司所有者的净利润  1671836.27  2707936.03  3520362.53\n",
       "21              少数股东损益   121228.04   192706.30   262599.25\n",
       "22              六、每股收益         NaN         NaN         NaN\n",
       "23         基本每股收益(元/股)       13.31       21.56       28.02\n",
       "24         稀释每股收益(元/股)       13.31       21.56       28.02\n",
       "25            七、其他综合收益      179.32      383.93       33.59\n",
       "26            八、综合收益总额  1793243.63  2901026.25  3782995.36\n",
       "27    归属于母公司所有者的综合收益总额  1672015.60  2708319.95  3520396.11\n",
       "28      归属于少数股东的综合收益总额   121228.04   192706.30   262599.25"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#获取近三年的利润表\n",
    "yearvalues1=[]\n",
    "for i in range(year-2,year+1):\n",
    "    profiturl='http://money.finance.sina.com.cn/corp/go.php/vFD_ProfitStatement/stockid/'+str(stockid)+'/ctrl/'+str(i)+'/displaytype/4.phtml'\n",
    "    profitxpath1='//*[@id=\"ProfitStatementNewTable0\"]/tbody//tr'\n",
    "    Accounts,values=sheet1(profiturl,profitxpath1)\n",
    "    yearvalues1.append(values)\n",
    "vFD_ProfitStatement=pd.DataFrame({'Accounts':Accounts})\n",
    "vFD_ProfitStatement[year-2]=yearvalues1[0]\n",
    "vFD_ProfitStatement[year-1]=yearvalues1[1]\n",
    "vFD_ProfitStatement[year]=yearvalues1[2]\n",
    "vFD_ProfitStatement"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:51.924570Z",
     "start_time": "2019-05-17T11:58:51.397671Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Accounts</th>\n",
       "      <th>2016</th>\n",
       "      <th>2017</th>\n",
       "      <th>2018</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>一、经营活动产生的现金流量</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>销售商品、提供劳务收到的现金</td>\n",
       "      <td>6101296.41</td>\n",
       "      <td>6442147.93</td>\n",
       "      <td>8426869.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>收到的税费返还</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>收到的其他与经营活动有关的现金</td>\n",
       "      <td>18914.27</td>\n",
       "      <td>54216.22</td>\n",
       "      <td>62155.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>经营活动现金流入小计</td>\n",
       "      <td>6727914.56</td>\n",
       "      <td>6736946.25</td>\n",
       "      <td>8934563.54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>购买商品、接受劳务支付的现金</td>\n",
       "      <td>277302.04</td>\n",
       "      <td>487576.85</td>\n",
       "      <td>529851.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>支付给职工以及为职工支付的现金</td>\n",
       "      <td>467415.42</td>\n",
       "      <td>548960.61</td>\n",
       "      <td>665313.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>支付的各项税费</td>\n",
       "      <td>1751051.63</td>\n",
       "      <td>2306564.85</td>\n",
       "      <td>3203217.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>支付的其他与经营活动有关的现金</td>\n",
       "      <td>237148.68</td>\n",
       "      <td>294029.64</td>\n",
       "      <td>293576.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>经营活动现金流出小计</td>\n",
       "      <td>2982789.60</td>\n",
       "      <td>4521642.64</td>\n",
       "      <td>4796040.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>经营活动产生的现金流量净额</td>\n",
       "      <td>3745124.96</td>\n",
       "      <td>2215303.61</td>\n",
       "      <td>4138523.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>二、投资活动产生的现金流量</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>收回投资所收到的现金</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>取得投资收益所收到的现金</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>处置固定资产、无形资产和其他长期资产所收回的现金净额</td>\n",
       "      <td>9.21</td>\n",
       "      <td>1.65</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>处置子公司及其他营业单位收到的现金净额</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>收到的其他与投资活动有关的现金</td>\n",
       "      <td>556.24</td>\n",
       "      <td>2143.07</td>\n",
       "      <td>1124.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>投资活动现金流入小计</td>\n",
       "      <td>565.44</td>\n",
       "      <td>2144.71</td>\n",
       "      <td>1124.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>购建固定资产、无形资产和其他长期资产所支付的现金</td>\n",
       "      <td>101917.81</td>\n",
       "      <td>112501.72</td>\n",
       "      <td>160675.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>投资所支付的现金</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>取得子公司及其他营业单位支付的现金净额</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>支付的其他与投资活动有关的现金</td>\n",
       "      <td>8897.71</td>\n",
       "      <td>1707.51</td>\n",
       "      <td>3345.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>投资活动现金流出小计</td>\n",
       "      <td>110815.52</td>\n",
       "      <td>114209.23</td>\n",
       "      <td>164020.69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>投资活动产生的现金流量净额</td>\n",
       "      <td>-110250.08</td>\n",
       "      <td>-112064.52</td>\n",
       "      <td>-162896.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>三、筹资活动产生的现金流量</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>吸收投资收到的现金</td>\n",
       "      <td>1600.00</td>\n",
       "      <td>600.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>其中：子公司吸收少数股东投资收到的现金</td>\n",
       "      <td>1600.00</td>\n",
       "      <td>600.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>取得借款收到的现金</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>发行债券收到的现金</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>收到其他与筹资活动有关的现金</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>资产减值准备</td>\n",
       "      <td>1232.75</td>\n",
       "      <td>-805.37</td>\n",
       "      <td>128.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>固定资产折旧、油气资产折耗、生产性物资折旧</td>\n",
       "      <td>84272.81</td>\n",
       "      <td>103505.27</td>\n",
       "      <td>108466.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>47</th>\n",
       "      <td>无形资产摊销</td>\n",
       "      <td>8045.79</td>\n",
       "      <td>8052.27</td>\n",
       "      <td>8043.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>48</th>\n",
       "      <td>长期待摊费用摊销</td>\n",
       "      <td>1100.87</td>\n",
       "      <td>1025.91</td>\n",
       "      <td>1033.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>待摊费用的减少</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>预提费用的增加</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>51</th>\n",
       "      <td>处置固定资产、无形资产和其他长期资产的损失</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>52</th>\n",
       "      <td>固定资产报废损失</td>\n",
       "      <td>186.99</td>\n",
       "      <td>329.19</td>\n",
       "      <td>180.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>53</th>\n",
       "      <td>公允价值变动损失</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>54</th>\n",
       "      <td>递延收益增加（减：减少）</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>预计负债</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>56</th>\n",
       "      <td>财务费用</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>投资损失</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>58</th>\n",
       "      <td>递延所得税资产减少</td>\n",
       "      <td>-59020.30</td>\n",
       "      <td>34374.18</td>\n",
       "      <td>35250.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>59</th>\n",
       "      <td>递延所得税负债增加</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>存货的减少</td>\n",
       "      <td>-260895.48</td>\n",
       "      <td>-143522.96</td>\n",
       "      <td>-144946.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>61</th>\n",
       "      <td>经营性应收项目的减少</td>\n",
       "      <td>766965.06</td>\n",
       "      <td>-45872.85</td>\n",
       "      <td>52566.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>62</th>\n",
       "      <td>经营性应付项目的增加</td>\n",
       "      <td>1410172.18</td>\n",
       "      <td>-642424.36</td>\n",
       "      <td>294839.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>63</th>\n",
       "      <td>已完工尚未结算款的减少(减:增加)</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>已结算尚未完工款的增加(减:减少)</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>65</th>\n",
       "      <td>其他</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>66</th>\n",
       "      <td>经营活动产生现金流量净额</td>\n",
       "      <td>3745124.96</td>\n",
       "      <td>2215303.61</td>\n",
       "      <td>4138523.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>67</th>\n",
       "      <td>债务转为资本</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>68</th>\n",
       "      <td>一年内到期的可转换公司债券</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>69</th>\n",
       "      <td>融资租入固定资产</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>70</th>\n",
       "      <td>现金的期末余额</td>\n",
       "      <td>6279479.48</td>\n",
       "      <td>7492808.08</td>\n",
       "      <td>9824328.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>71</th>\n",
       "      <td>现金的期初余额</td>\n",
       "      <td>3478048.59</td>\n",
       "      <td>6279479.48</td>\n",
       "      <td>7492808.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>72</th>\n",
       "      <td>现金等价物的期末余额</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>73</th>\n",
       "      <td>现金等价物的期初余额</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>74</th>\n",
       "      <td>现金及现金等价物的净增加额</td>\n",
       "      <td>2801430.89</td>\n",
       "      <td>1213328.59</td>\n",
       "      <td>2331520.75</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>75 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                      Accounts        2016        2017        2018\n",
       "0                一、经营活动产生的现金流量         NaN         NaN         NaN\n",
       "1               销售商品、提供劳务收到的现金  6101296.41  6442147.93  8426869.57\n",
       "2                      收到的税费返还        0.00        0.00        0.00\n",
       "3              收到的其他与经营活动有关的现金    18914.27    54216.22    62155.84\n",
       "4                   经营活动现金流入小计  6727914.56  6736946.25  8934563.54\n",
       "5               购买商品、接受劳务支付的现金   277302.04   487576.85   529851.80\n",
       "6              支付给职工以及为职工支付的现金   467415.42   548960.61   665313.77\n",
       "7                      支付的各项税费  1751051.63  2306564.85  3203217.81\n",
       "8              支付的其他与经营活动有关的现金   237148.68   294029.64   293576.68\n",
       "9                   经营活动现金流出小计  2982789.60  4521642.64  4796040.10\n",
       "10               经营活动产生的现金流量净额  3745124.96  2215303.61  4138523.44\n",
       "11               二、投资活动产生的现金流量         NaN         NaN         NaN\n",
       "12                  收回投资所收到的现金        0.00        0.00        0.00\n",
       "13                取得投资收益所收到的现金        0.00        0.00        0.00\n",
       "14  处置固定资产、无形资产和其他长期资产所收回的现金净额        9.21        1.65        0.00\n",
       "15         处置子公司及其他营业单位收到的现金净额        0.00        0.00        0.00\n",
       "16             收到的其他与投资活动有关的现金      556.24     2143.07     1124.42\n",
       "17                  投资活动现金流入小计      565.44     2144.71     1124.42\n",
       "18    购建固定资产、无形资产和其他长期资产所支付的现金   101917.81   112501.72   160675.02\n",
       "19                    投资所支付的现金        0.00        0.00        0.00\n",
       "20         取得子公司及其他营业单位支付的现金净额        0.00        0.00        0.00\n",
       "21             支付的其他与投资活动有关的现金     8897.71     1707.51     3345.67\n",
       "22                  投资活动现金流出小计   110815.52   114209.23   164020.69\n",
       "23               投资活动产生的现金流量净额  -110250.08  -112064.52  -162896.27\n",
       "24               三、筹资活动产生的现金流量         NaN         NaN         NaN\n",
       "25                   吸收投资收到的现金     1600.00      600.00        0.00\n",
       "26         其中：子公司吸收少数股东投资收到的现金     1600.00      600.00        0.00\n",
       "27                   取得借款收到的现金        0.00        0.00        0.00\n",
       "28                   发行债券收到的现金        0.00        0.00        0.00\n",
       "29              收到其他与筹资活动有关的现金        0.00        0.00        0.00\n",
       "..                         ...         ...         ...         ...\n",
       "45                      资产减值准备     1232.75     -805.37      128.97\n",
       "46       固定资产折旧、油气资产折耗、生产性物资折旧    84272.81   103505.27   108466.27\n",
       "47                      无形资产摊销     8045.79     8052.27     8043.17\n",
       "48                    长期待摊费用摊销     1100.87     1025.91     1033.11\n",
       "49                     待摊费用的减少        0.00        0.00        0.00\n",
       "50                     预提费用的增加        0.00        0.00        0.00\n",
       "51       处置固定资产、无形资产和其他长期资产的损失        0.00        0.00        0.00\n",
       "52                    固定资产报废损失      186.99      329.19      180.89\n",
       "53                    公允价值变动损失        0.00        0.00        0.00\n",
       "54                递延收益增加（减：减少）        0.00        0.00        0.00\n",
       "55                        预计负债        0.00        0.00        0.00\n",
       "56                        财务费用        0.00        0.00        0.00\n",
       "57                        投资损失        0.00        0.00        0.00\n",
       "58                   递延所得税资产减少   -59020.30    34374.18    35250.25\n",
       "59                   递延所得税负债增加        0.00        0.00        0.00\n",
       "60                       存货的减少  -260895.48  -143522.96  -144946.95\n",
       "61                  经营性应收项目的减少   766965.06   -45872.85    52566.50\n",
       "62                  经营性应付项目的增加  1410172.18  -642424.36   294839.44\n",
       "63           已完工尚未结算款的减少(减:增加)        0.00        0.00        0.00\n",
       "64           已结算尚未完工款的增加(减:减少)        0.00        0.00        0.00\n",
       "65                          其他        0.00        0.00        0.00\n",
       "66                经营活动产生现金流量净额  3745124.96  2215303.61  4138523.44\n",
       "67                      债务转为资本        0.00        0.00        0.00\n",
       "68               一年内到期的可转换公司债券        0.00        0.00        0.00\n",
       "69                    融资租入固定资产        0.00        0.00        0.00\n",
       "70                     现金的期末余额  6279479.48  7492808.08  9824328.83\n",
       "71                     现金的期初余额  3478048.59  6279479.48  7492808.08\n",
       "72                  现金等价物的期末余额        0.00        0.00        0.00\n",
       "73                  现金等价物的期初余额        0.00        0.00        0.00\n",
       "74               现金及现金等价物的净增加额  2801430.89  1213328.59  2331520.75\n",
       "\n",
       "[75 rows x 4 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#获取近三年时间的现金流量表\n",
    "cashvalues=[]\n",
    "for i in range(year-2,year+1):\n",
    "    cashflowurl='http://money.finance.sina.com.cn/corp/go.php/vFD_CashFlow/stockid/'+str(stockid)+'/ctrl/'+str(i)+'/displaytype/4.phtml'\n",
    "    cashxpath='//*[@id=\"ProfitStatementNewTable0\"]/tbody//tr'\n",
    "    Accounts,cash=sheet1(cashflowurl,cashxpath)\n",
    "    cashvalues.append(cash)\n",
    "vFD_CashFlow=pd.DataFrame({'Accounts':Accounts})\n",
    "vFD_CashFlow[year-2]=cashvalues[0]\n",
    "vFD_CashFlow[year-1]=cashvalues[1]\n",
    "vFD_CashFlow[year]=cashvalues[2]\n",
    "vFD_CashFlow"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:51.965590Z",
     "start_time": "2019-05-17T11:58:51.931570Z"
    },
    "code_folding": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>营业收入</th>\n",
       "      <th>营业成本</th>\n",
       "      <th>销售费用</th>\n",
       "      <th>管理费用</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>3886219.00</td>\n",
       "      <td>341010.41</td>\n",
       "      <td>168105.20</td>\n",
       "      <td>418718.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>5821786.13</td>\n",
       "      <td>594043.64</td>\n",
       "      <td>298606.85</td>\n",
       "      <td>472054.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>7363887.24</td>\n",
       "      <td>652292.18</td>\n",
       "      <td>257207.69</td>\n",
       "      <td>532594.08</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            营业收入       营业成本       销售费用       管理费用\n",
       "2016  3886219.00  341010.41  168105.20  418718.98\n",
       "2017  5821786.13  594043.64  298606.85  472054.28\n",
       "2018  7363887.24  652292.18  257207.69  532594.08"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#将需要的营业收入，营业成本，管理费用，销售费用取出\n",
    "everyvalues=vFD_ProfitStatement.loc[(vFD_ProfitStatement['Accounts']=='营业收入')|\n",
    "                                    (vFD_ProfitStatement['Accounts']=='营业成本')|\n",
    "                                   (vFD_ProfitStatement['Accounts']=='销售费用')|\n",
    "                                   (vFD_ProfitStatement['Accounts']=='管理费用')]\n",
    "everyvalues1=np.array(everyvalues.iloc[:,[1,2,3]])\n",
    "total=pd.DataFrame({'营业收入':everyvalues1[0],\n",
    "                    '营业成本':everyvalues1[1],\n",
    "                    '销售费用':everyvalues1[2],\n",
    "                    '管理费用':everyvalues1[3]},\n",
    "                   index=[year-2,year-1,year])\n",
    "total"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.008577Z",
     "start_time": "2019-05-17T11:58:51.971572Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>营业收入</th>\n",
       "      <th>营业成本</th>\n",
       "      <th>销售费用</th>\n",
       "      <th>管理费用</th>\n",
       "      <th>折旧与摊销</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>3886219.00</td>\n",
       "      <td>341010.41</td>\n",
       "      <td>168105.20</td>\n",
       "      <td>418718.98</td>\n",
       "      <td>93419.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>5821786.13</td>\n",
       "      <td>594043.64</td>\n",
       "      <td>298606.85</td>\n",
       "      <td>472054.28</td>\n",
       "      <td>112583.45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>7363887.24</td>\n",
       "      <td>652292.18</td>\n",
       "      <td>257207.69</td>\n",
       "      <td>532594.08</td>\n",
       "      <td>117542.55</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            营业收入       营业成本       销售费用       管理费用      折旧与摊销\n",
       "2016  3886219.00  341010.41  168105.20  418718.98   93419.47\n",
       "2017  5821786.13  594043.64  298606.85  472054.28  112583.45\n",
       "2018  7363887.24  652292.18  257207.69  532594.08  117542.55"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#计算折旧与摊销的总额，并将其合并到上述表格中\n",
    "Amort=vFD_CashFlow[(vFD_CashFlow['Accounts']=='固定资产折旧、油气资产折耗、生产性物资折旧')|\n",
    "                   (vFD_CashFlow['Accounts']=='无形资产摊销')|\n",
    "                   (vFD_CashFlow['Accounts']=='长期待摊费用摊销')]\n",
    "#计算三者每一年的总和\n",
    "Amort1=Amort.sum(axis=0)\n",
    "Amort2=list(Amort1[1:])\n",
    "total['折旧与摊销']=Amort2\n",
    "total"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.076581Z",
     "start_time": "2019-05-17T11:58:52.012573Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>营业收入</th>\n",
       "      <th>营业成本</th>\n",
       "      <th>销售费用</th>\n",
       "      <th>管理费用</th>\n",
       "      <th>折旧与摊销</th>\n",
       "      <th>不包括折旧与摊销的营业成本</th>\n",
       "      <th>销售管理以及行政费用</th>\n",
       "      <th>息前税前折旧摊销前利润（EBITDA）</th>\n",
       "      <th>EBIT</th>\n",
       "      <th>息前税后利润</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>3886219.00</td>\n",
       "      <td>341010.41</td>\n",
       "      <td>168105.20</td>\n",
       "      <td>418718.98</td>\n",
       "      <td>93419.47</td>\n",
       "      <td>247590.94</td>\n",
       "      <td>586824.18</td>\n",
       "      <td>3051803.88</td>\n",
       "      <td>2958384.41</td>\n",
       "      <td>2.218788e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>5821786.13</td>\n",
       "      <td>594043.64</td>\n",
       "      <td>298606.85</td>\n",
       "      <td>472054.28</td>\n",
       "      <td>112583.45</td>\n",
       "      <td>481460.19</td>\n",
       "      <td>770661.13</td>\n",
       "      <td>4569664.81</td>\n",
       "      <td>4457081.36</td>\n",
       "      <td>3.342811e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>7363887.24</td>\n",
       "      <td>652292.18</td>\n",
       "      <td>257207.69</td>\n",
       "      <td>532594.08</td>\n",
       "      <td>117542.55</td>\n",
       "      <td>534749.63</td>\n",
       "      <td>789801.77</td>\n",
       "      <td>6039335.84</td>\n",
       "      <td>5921793.29</td>\n",
       "      <td>4.441345e+06</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            营业收入       营业成本       销售费用       管理费用      折旧与摊销  不包括折旧与摊销的营业成本  \\\n",
       "2016  3886219.00  341010.41  168105.20  418718.98   93419.47      247590.94   \n",
       "2017  5821786.13  594043.64  298606.85  472054.28  112583.45      481460.19   \n",
       "2018  7363887.24  652292.18  257207.69  532594.08  117542.55      534749.63   \n",
       "\n",
       "      销售管理以及行政费用  息前税前折旧摊销前利润（EBITDA）        EBIT        息前税后利润  \n",
       "2016   586824.18           3051803.88  2958384.41  2.218788e+06  \n",
       "2017   770661.13           4569664.81  4457081.36  3.342811e+06  \n",
       "2018   789801.77           6039335.84  5921793.29  4.441345e+06  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#计算不包括折旧与摊销的营业成本\n",
    "total['不包括折旧与摊销的营业成本']=total['营业成本']-total['折旧与摊销']\n",
    "#计算销售与管理费用总和\n",
    "total['销售管理以及行政费用']=total['销售费用']+total['管理费用']\n",
    "#计算息前税前折旧摊销前利润（EBITDA）\n",
    "total['息前税前折旧摊销前利润（EBITDA）']=total['营业收入']-total['不包括折旧与摊销的营业成本']-total['销售管理以及行政费用']\n",
    "total['EBIT']=total['息前税前折旧摊销前利润（EBITDA）']-total['折旧与摊销']\n",
    "total['息前税后利润']=total['EBIT']*(1-Tax)\n",
    "total#这个表是为了查看各个指标的情况"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.116583Z",
     "start_time": "2019-05-17T11:58:52.082580Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>营业收入</th>\n",
       "      <th>不包括折旧与摊销的营业成本</th>\n",
       "      <th>销售管理以及行政费用</th>\n",
       "      <th>折旧与摊销</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>3886219.00</td>\n",
       "      <td>247590.94</td>\n",
       "      <td>586824.18</td>\n",
       "      <td>93419.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>5821786.13</td>\n",
       "      <td>481460.19</td>\n",
       "      <td>770661.13</td>\n",
       "      <td>112583.45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>7363887.24</td>\n",
       "      <td>534749.63</td>\n",
       "      <td>789801.77</td>\n",
       "      <td>117542.55</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            营业收入  不包括折旧与摊销的营业成本  销售管理以及行政费用      折旧与摊销\n",
       "2016  3886219.00      247590.94   586824.18   93419.47\n",
       "2017  5821786.13      481460.19   770661.13  112583.45\n",
       "2018  7363887.24      534749.63   789801.77  117542.55"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#接下来计算预测期（预测期为10年）的息前税后利润\n",
    "#计算营业收入前三年的增长率以及其均值\n",
    "total1=total.loc[:,['营业收入','不包括折旧与摊销的营业成本','销售管理以及行政费用','折旧与摊销']]\n",
    "total1['营业收入增长率']=(total1['营业收入']/total1['营业收入'].shift(1))-1\n",
    "total1['不包括折旧与摊销的营业成本占营业收入']=total1['不包括折旧与摊销的营业成本']/total1['营业收入']\n",
    "total1['销售管理费用占营业收入']=total1['销售管理以及行政费用']/total1['营业收入']\n",
    "total1['折旧摊销占营业收入']=total1['折旧与摊销']/total1['营业收入']\n",
    "total2=total1.loc[:,['营业收入','不包括折旧与摊销的营业成本','销售管理以及行政费用','折旧与摊销']]\n",
    "total2#此表将会作为总体进行预测"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.131585Z",
     "start_time": "2019-05-17T11:58:52.122587Z"
    }
   },
   "outputs": [],
   "source": [
    "meanprofit=total1['营业收入增长率'].mean()\n",
    "meancost=total1['不包括折旧与摊销的营业成本占营业收入'].mean()\n",
    "meanfee=total1['销售管理费用占营业收入'].mean()\n",
    "meanzhe=total1['折旧摊销占营业收入'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.175590Z",
     "start_time": "2019-05-17T11:58:52.135584Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>营业收入</th>\n",
       "      <th>不包括折旧与摊销的营业成本</th>\n",
       "      <th>销售管理以及行政费用</th>\n",
       "      <th>折旧与摊销</th>\n",
       "      <th>资本性支出</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>3886219.00</td>\n",
       "      <td>247590.94</td>\n",
       "      <td>586824.18</td>\n",
       "      <td>93419.47</td>\n",
       "      <td>101917.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>5821786.13</td>\n",
       "      <td>481460.19</td>\n",
       "      <td>770661.13</td>\n",
       "      <td>112583.45</td>\n",
       "      <td>112501.72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>7363887.24</td>\n",
       "      <td>534749.63</td>\n",
       "      <td>789801.77</td>\n",
       "      <td>117542.55</td>\n",
       "      <td>160675.02</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            营业收入  不包括折旧与摊销的营业成本  销售管理以及行政费用      折旧与摊销      资本性支出\n",
       "2016  3886219.00      247590.94   586824.18   93419.47  101917.81\n",
       "2017  5821786.13      481460.19   770661.13  112583.45  112501.72\n",
       "2018  7363887.24      534749.63   789801.77  117542.55  160675.02"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#资本性支出，即当期固定资产投资净额，在现金流量表中的投资活动列示\n",
    "Assetsinvestment=vFD_CashFlow[vFD_CashFlow['Accounts']=='购建固定资产、无形资产和其他长期资产所支付的现金']\n",
    "Assetsinvestment1=np.array(Assetsinvestment.iloc[:,[1,2,3]])\n",
    "total2['资本性支出']=Assetsinvestment1[0]\n",
    "total2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.202590Z",
     "start_time": "2019-05-17T11:58:52.179588Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.02245634157731856"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#计算资本性支出平均增长率\n",
    "capitalzhichu=total2['资本性支出']/total2['营业收入']\n",
    "meanzhichu=capitalzhichu.mean()\n",
    "meanzhichu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.254594Z",
     "start_time": "2019-05-17T11:58:52.205589Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Accounts</th>\n",
       "      <th>2016</th>\n",
       "      <th>2017</th>\n",
       "      <th>2018</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>应收账款</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>存货</td>\n",
       "      <td>2062225.18</td>\n",
       "      <td>2205748.14</td>\n",
       "      <td>2350695.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>流动资产合计</td>\n",
       "      <td>9018054.88</td>\n",
       "      <td>11224918.60</td>\n",
       "      <td>13786183.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>应付账款</td>\n",
       "      <td>104060.82</td>\n",
       "      <td>99205.59</td>\n",
       "      <td>117829.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>流动负债合计</td>\n",
       "      <td>3702042.54</td>\n",
       "      <td>3857491.94</td>\n",
       "      <td>4243818.68</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Accounts        2016         2017         2018\n",
       "5      应收账款        0.00         0.00         0.00\n",
       "11       存货  2062225.18   2205748.14   2350695.08\n",
       "17   流动资产合计  9018054.88  11224918.60  13786183.53\n",
       "44     应付账款   104060.82     99205.59    117829.64\n",
       "57   流动负债合计  3702042.54   3857491.94   4243818.68"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#营运资本估算，筛选相关科目\n",
    "capital1=data1[(data1['Accounts']=='流动资产合计')|\n",
    "              (data1['Accounts']=='应收账款')|\n",
    "              (data1['Accounts']=='存货')|\n",
    "              (data1['Accounts']=='流动负债合计')|\n",
    "              (data1['Accounts']=='应付账款')]\n",
    "capital1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.314595Z",
     "start_time": "2019-05-17T11:58:52.259593Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>营业收入</th>\n",
       "      <th>营业成本</th>\n",
       "      <th>销售费用</th>\n",
       "      <th>管理费用</th>\n",
       "      <th>折旧与摊销</th>\n",
       "      <th>不包括折旧与摊销的营业成本</th>\n",
       "      <th>销售管理以及行政费用</th>\n",
       "      <th>息前税前折旧摊销前利润（EBITDA）</th>\n",
       "      <th>EBIT</th>\n",
       "      <th>息前税后利润</th>\n",
       "      <th>应收账款</th>\n",
       "      <th>存货</th>\n",
       "      <th>流动资产合计</th>\n",
       "      <th>应付账款</th>\n",
       "      <th>流动负债合计</th>\n",
       "      <th>应收账款周转天数</th>\n",
       "      <th>存货周转天数</th>\n",
       "      <th>其他流动资产占销售收入</th>\n",
       "      <th>应付账款周转天数</th>\n",
       "      <th>其他流动负债占销货成本</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>3886219.00</td>\n",
       "      <td>341010.41</td>\n",
       "      <td>168105.20</td>\n",
       "      <td>418718.98</td>\n",
       "      <td>93419.47</td>\n",
       "      <td>247590.94</td>\n",
       "      <td>586824.18</td>\n",
       "      <td>3051803.88</td>\n",
       "      <td>2958384.41</td>\n",
       "      <td>2.218788e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2062225.18</td>\n",
       "      <td>9018054.88</td>\n",
       "      <td>104060.82</td>\n",
       "      <td>3702042.54</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3040.144323</td>\n",
       "      <td>1.789871</td>\n",
       "      <td>153.407064</td>\n",
       "      <td>14.531960</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>5821786.13</td>\n",
       "      <td>594043.64</td>\n",
       "      <td>298606.85</td>\n",
       "      <td>472054.28</td>\n",
       "      <td>112583.45</td>\n",
       "      <td>481460.19</td>\n",
       "      <td>770661.13</td>\n",
       "      <td>4569664.81</td>\n",
       "      <td>4457081.36</td>\n",
       "      <td>3.342811e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2205748.14</td>\n",
       "      <td>11224918.60</td>\n",
       "      <td>99205.59</td>\n",
       "      <td>3857491.94</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1672.200709</td>\n",
       "      <td>1.549210</td>\n",
       "      <td>75.208794</td>\n",
       "      <td>7.806017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>7363887.24</td>\n",
       "      <td>652292.18</td>\n",
       "      <td>257207.69</td>\n",
       "      <td>532594.08</td>\n",
       "      <td>117542.55</td>\n",
       "      <td>534749.63</td>\n",
       "      <td>789801.77</td>\n",
       "      <td>6039335.84</td>\n",
       "      <td>5921793.29</td>\n",
       "      <td>4.441345e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2350695.08</td>\n",
       "      <td>13786183.53</td>\n",
       "      <td>117829.64</td>\n",
       "      <td>4243818.68</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1604.496116</td>\n",
       "      <td>1.552915</td>\n",
       "      <td>80.426084</td>\n",
       "      <td>7.715740</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            营业收入       营业成本       销售费用       管理费用      折旧与摊销  不包括折旧与摊销的营业成本  \\\n",
       "2016  3886219.00  341010.41  168105.20  418718.98   93419.47      247590.94   \n",
       "2017  5821786.13  594043.64  298606.85  472054.28  112583.45      481460.19   \n",
       "2018  7363887.24  652292.18  257207.69  532594.08  117542.55      534749.63   \n",
       "\n",
       "      销售管理以及行政费用  息前税前折旧摊销前利润（EBITDA）        EBIT        息前税后利润  应收账款  \\\n",
       "2016   586824.18           3051803.88  2958384.41  2.218788e+06   0.0   \n",
       "2017   770661.13           4569664.81  4457081.36  3.342811e+06   0.0   \n",
       "2018   789801.77           6039335.84  5921793.29  4.441345e+06   0.0   \n",
       "\n",
       "              存货       流动资产合计       应付账款      流动负债合计  应收账款周转天数       存货周转天数  \\\n",
       "2016  2062225.18   9018054.88  104060.82  3702042.54       0.0  3040.144323   \n",
       "2017  2205748.14  11224918.60   99205.59  3857491.94       0.0  1672.200709   \n",
       "2018  2350695.08  13786183.53  117829.64  4243818.68       0.0  1604.496116   \n",
       "\n",
       "      其他流动资产占销售收入    应付账款周转天数  其他流动负债占销货成本  \n",
       "2016     1.789871  153.407064    14.531960  \n",
       "2017     1.549210   75.208794     7.806017  \n",
       "2018     1.552915   80.426084     7.715740  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#计算相关指标\n",
    "capital2=np.array(capital1.iloc[:,[1,2,3]])\n",
    "total['应收账款']=capital2[0]\n",
    "total['存货']=capital2[1]\n",
    "total['流动资产合计']=capital2[2]\n",
    "total['应付账款']=capital2[3]\n",
    "total['流动负债合计']=capital2[4]\n",
    "total['应收账款周转天数']=total['应收账款']/total['营业收入']*365\n",
    "total['存货周转天数']=total['存货']/total['不包括折旧与摊销的营业成本']*365\n",
    "total['其他流动资产占销售收入']=(total['流动资产合计']-total['应收账款']-total['存货'])/total['营业收入']\n",
    "total['应付账款周转天数']=total['应付账款']/total['不包括折旧与摊销的营业成本']*365\n",
    "total['其他流动负债占销货成本']=(total['流动负债合计']-total['应付账款'])/total['不包括折旧与摊销的营业成本']\n",
    "total"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.339603Z",
     "start_time": "2019-05-17T11:58:52.317599Z"
    }
   },
   "outputs": [],
   "source": [
    "#计算一些指标的均值\n",
    "meanyingshou=total['应收账款周转天数'].mean()\n",
    "meancun=total['存货周转天数'].mean()\n",
    "meanqitaliudong=total['其他流动资产占销售收入'].mean()\n",
    "meanyingfu=total['应付账款周转天数'].mean()\n",
    "meanqtfz=total['其他流动负债占销货成本'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.380604Z",
     "start_time": "2019-05-17T11:58:52.343601Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>营业收入</th>\n",
       "      <th>不包括折旧与摊销的营业成本</th>\n",
       "      <th>销售管理以及行政费用</th>\n",
       "      <th>折旧与摊销</th>\n",
       "      <th>资本性支出</th>\n",
       "      <th>应收账款</th>\n",
       "      <th>存货</th>\n",
       "      <th>其它流动资产合计</th>\n",
       "      <th>应付账款</th>\n",
       "      <th>其他流动负债合计</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>3886219.00</td>\n",
       "      <td>247590.94</td>\n",
       "      <td>586824.18</td>\n",
       "      <td>93419.47</td>\n",
       "      <td>101917.81</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2062225.18</td>\n",
       "      <td>6955829.70</td>\n",
       "      <td>104060.82</td>\n",
       "      <td>3597981.72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>5821786.13</td>\n",
       "      <td>481460.19</td>\n",
       "      <td>770661.13</td>\n",
       "      <td>112583.45</td>\n",
       "      <td>112501.72</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2205748.14</td>\n",
       "      <td>9019170.46</td>\n",
       "      <td>99205.59</td>\n",
       "      <td>3758286.35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>7363887.24</td>\n",
       "      <td>534749.63</td>\n",
       "      <td>789801.77</td>\n",
       "      <td>117542.55</td>\n",
       "      <td>160675.02</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2350695.08</td>\n",
       "      <td>11435488.45</td>\n",
       "      <td>117829.64</td>\n",
       "      <td>4125989.04</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            营业收入  不包括折旧与摊销的营业成本  销售管理以及行政费用      折旧与摊销      资本性支出  应收账款  \\\n",
       "2016  3886219.00      247590.94   586824.18   93419.47  101917.81   0.0   \n",
       "2017  5821786.13      481460.19   770661.13  112583.45  112501.72   0.0   \n",
       "2018  7363887.24      534749.63   789801.77  117542.55  160675.02   0.0   \n",
       "\n",
       "              存货     其它流动资产合计       应付账款    其他流动负债合计  \n",
       "2016  2062225.18   6955829.70  104060.82  3597981.72  \n",
       "2017  2205748.14   9019170.46   99205.59  3758286.35  \n",
       "2018  2350695.08  11435488.45  117829.64  4125989.04  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#将一些科目合并进total2中\n",
    "total2['应收账款']=capital2[0]\n",
    "total2['存货']=capital2[1]\n",
    "total2['其它流动资产合计']=total['流动资产合计']-total['应收账款']-total['存货']\n",
    "total2['应付账款']=capital2[3]\n",
    "total2['其他流动负债合计']=total['流动负债合计']-total['应付账款']\n",
    "total2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.431606Z",
     "start_time": "2019-05-17T11:58:52.385608Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>营业收入</th>\n",
       "      <th>不包括折旧与摊销的营业成本</th>\n",
       "      <th>销售管理以及行政费用</th>\n",
       "      <th>折旧与摊销</th>\n",
       "      <th>资本性支出</th>\n",
       "      <th>应收账款</th>\n",
       "      <th>存货</th>\n",
       "      <th>其它流动资产合计</th>\n",
       "      <th>应付账款</th>\n",
       "      <th>其他流动负债合计</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>3.886219e+06</td>\n",
       "      <td>2.475909e+05</td>\n",
       "      <td>5.868242e+05</td>\n",
       "      <td>9.341947e+04</td>\n",
       "      <td>1.019178e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.062225e+06</td>\n",
       "      <td>6.955830e+06</td>\n",
       "      <td>1.040608e+05</td>\n",
       "      <td>3.597982e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>5.821786e+06</td>\n",
       "      <td>4.814602e+05</td>\n",
       "      <td>7.706611e+05</td>\n",
       "      <td>1.125835e+05</td>\n",
       "      <td>1.125017e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.205748e+06</td>\n",
       "      <td>9.019170e+06</td>\n",
       "      <td>9.920559e+04</td>\n",
       "      <td>3.758286e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>7.363887e+06</td>\n",
       "      <td>5.347496e+05</td>\n",
       "      <td>7.898018e+05</td>\n",
       "      <td>1.175426e+05</td>\n",
       "      <td>1.606750e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.350695e+06</td>\n",
       "      <td>1.143549e+07</td>\n",
       "      <td>1.178296e+05</td>\n",
       "      <td>4.125989e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019</th>\n",
       "      <td>1.017300e+07</td>\n",
       "      <td>7.427227e+05</td>\n",
       "      <td>1.324627e+06</td>\n",
       "      <td>2.012185e+05</td>\n",
       "      <td>2.284484e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.284622e+06</td>\n",
       "      <td>1.658876e+07</td>\n",
       "      <td>2.096187e+05</td>\n",
       "      <td>7.440526e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020</th>\n",
       "      <td>1.405372e+07</td>\n",
       "      <td>1.026051e+06</td>\n",
       "      <td>1.829935e+06</td>\n",
       "      <td>2.779777e+05</td>\n",
       "      <td>3.155951e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.919085e+06</td>\n",
       "      <td>2.291691e+07</td>\n",
       "      <td>2.895823e+05</td>\n",
       "      <td>1.027888e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021</th>\n",
       "      <td>1.941482e+07</td>\n",
       "      <td>1.417460e+06</td>\n",
       "      <td>2.528004e+06</td>\n",
       "      <td>3.840184e+05</td>\n",
       "      <td>4.359857e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>8.177049e+06</td>\n",
       "      <td>3.165906e+07</td>\n",
       "      <td>4.000498e+05</td>\n",
       "      <td>1.419998e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022</th>\n",
       "      <td>2.682102e+07</td>\n",
       "      <td>1.958181e+06</td>\n",
       "      <td>3.492366e+06</td>\n",
       "      <td>5.305107e+05</td>\n",
       "      <td>6.023020e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.129636e+07</td>\n",
       "      <td>4.373611e+07</td>\n",
       "      <td>5.526576e+05</td>\n",
       "      <td>1.961687e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023</th>\n",
       "      <td>3.705249e+07</td>\n",
       "      <td>2.705172e+06</td>\n",
       "      <td>4.824605e+06</td>\n",
       "      <td>7.328856e+05</td>\n",
       "      <td>8.320633e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.560561e+07</td>\n",
       "      <td>6.042020e+07</td>\n",
       "      <td>7.634809e+05</td>\n",
       "      <td>2.710016e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2024</th>\n",
       "      <td>5.118697e+07</td>\n",
       "      <td>3.737119e+06</td>\n",
       "      <td>6.665056e+06</td>\n",
       "      <td>1.012461e+06</td>\n",
       "      <td>1.149472e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.155871e+07</td>\n",
       "      <td>8.346881e+07</td>\n",
       "      <td>1.054727e+06</td>\n",
       "      <td>3.743811e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025</th>\n",
       "      <td>7.071336e+07</td>\n",
       "      <td>5.162725e+06</td>\n",
       "      <td>9.207588e+06</td>\n",
       "      <td>1.398686e+06</td>\n",
       "      <td>1.587963e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.978275e+07</td>\n",
       "      <td>1.153098e+08</td>\n",
       "      <td>1.457076e+06</td>\n",
       "      <td>5.171969e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2026</th>\n",
       "      <td>9.768851e+07</td>\n",
       "      <td>7.132159e+06</td>\n",
       "      <td>1.272002e+07</td>\n",
       "      <td>1.932245e+06</td>\n",
       "      <td>2.193727e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.114403e+07</td>\n",
       "      <td>1.592973e+08</td>\n",
       "      <td>2.012910e+06</td>\n",
       "      <td>7.144930e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2027</th>\n",
       "      <td>1.349539e+08</td>\n",
       "      <td>9.852877e+06</td>\n",
       "      <td>1.757235e+07</td>\n",
       "      <td>2.669343e+06</td>\n",
       "      <td>3.030572e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.683932e+07</td>\n",
       "      <td>2.200647e+08</td>\n",
       "      <td>2.780778e+06</td>\n",
       "      <td>9.870519e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2028</th>\n",
       "      <td>1.864351e+08</td>\n",
       "      <td>1.361147e+07</td>\n",
       "      <td>2.427571e+07</td>\n",
       "      <td>3.687622e+06</td>\n",
       "      <td>4.186649e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7.852193e+07</td>\n",
       "      <td>3.040132e+08</td>\n",
       "      <td>3.841567e+06</td>\n",
       "      <td>1.363584e+08</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              营业收入  不包括折旧与摊销的营业成本    销售管理以及行政费用         折旧与摊销         资本性支出  \\\n",
       "2016  3.886219e+06   2.475909e+05  5.868242e+05  9.341947e+04  1.019178e+05   \n",
       "2017  5.821786e+06   4.814602e+05  7.706611e+05  1.125835e+05  1.125017e+05   \n",
       "2018  7.363887e+06   5.347496e+05  7.898018e+05  1.175426e+05  1.606750e+05   \n",
       "2019  1.017300e+07   7.427227e+05  1.324627e+06  2.012185e+05  2.284484e+05   \n",
       "2020  1.405372e+07   1.026051e+06  1.829935e+06  2.779777e+05  3.155951e+05   \n",
       "2021  1.941482e+07   1.417460e+06  2.528004e+06  3.840184e+05  4.359857e+05   \n",
       "2022  2.682102e+07   1.958181e+06  3.492366e+06  5.305107e+05  6.023020e+05   \n",
       "2023  3.705249e+07   2.705172e+06  4.824605e+06  7.328856e+05  8.320633e+05   \n",
       "2024  5.118697e+07   3.737119e+06  6.665056e+06  1.012461e+06  1.149472e+06   \n",
       "2025  7.071336e+07   5.162725e+06  9.207588e+06  1.398686e+06  1.587963e+06   \n",
       "2026  9.768851e+07   7.132159e+06  1.272002e+07  1.932245e+06  2.193727e+06   \n",
       "2027  1.349539e+08   9.852877e+06  1.757235e+07  2.669343e+06  3.030572e+06   \n",
       "2028  1.864351e+08   1.361147e+07  2.427571e+07  3.687622e+06  4.186649e+06   \n",
       "\n",
       "      应收账款            存货      其它流动资产合计          应付账款      其他流动负债合计  \n",
       "2016   0.0  2.062225e+06  6.955830e+06  1.040608e+05  3.597982e+06  \n",
       "2017   0.0  2.205748e+06  9.019170e+06  9.920559e+04  3.758286e+06  \n",
       "2018   0.0  2.350695e+06  1.143549e+07  1.178296e+05  4.125989e+06  \n",
       "2019   0.0  4.284622e+06  1.658876e+07  2.096187e+05  7.440526e+06  \n",
       "2020   0.0  5.919085e+06  2.291691e+07  2.895823e+05  1.027888e+07  \n",
       "2021   0.0  8.177049e+06  3.165906e+07  4.000498e+05  1.419998e+07  \n",
       "2022   0.0  1.129636e+07  4.373611e+07  5.526576e+05  1.961687e+07  \n",
       "2023   0.0  1.560561e+07  6.042020e+07  7.634809e+05  2.710016e+07  \n",
       "2024   0.0  2.155871e+07  8.346881e+07  1.054727e+06  3.743811e+07  \n",
       "2025   0.0  2.978275e+07  1.153098e+08  1.457076e+06  5.171969e+07  \n",
       "2026   0.0  4.114403e+07  1.592973e+08  2.012910e+06  7.144930e+07  \n",
       "2027   0.0  5.683932e+07  2.200647e+08  2.780778e+06  9.870519e+07  \n",
       "2028   0.0  7.852193e+07  3.040132e+08  3.841567e+06  1.363584e+08  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "for i in range(1,11):\n",
    "    newprofit=total2.loc[year+i-1,'营业收入']*(1+meanprofit)#本期营业收入\n",
    "    total2.loc[year+i]=[newprofit,\n",
    "                        newprofit*meancost,#本期营业收入乘以营业成本占比\n",
    "                        newprofit*meanfee,#本期营业收入乘以管理费用占比\n",
    "                        newprofit*meanzhe,#本期营业收入乘以折旧与摊销占比\n",
    "                        newprofit*meanzhichu,#本期资本性支出等于本期营业收入乘以资本性支出比重\n",
    "                        newprofit/365*meanyingshou,#本期应收账款\n",
    "                        newprofit*meancost/365*meancun,#本期存货\n",
    "                        newprofit*meanqitaliudong,#本期其他流动资产合计\n",
    "                        newprofit*meancost/365*meanyingfu,#营业收入乘以营业成本占比。再除365天，乘以应付账款周转天数\n",
    "                        newprofit*meancost*meanqtfz]#其他流动负债，他等于本期营业成本乘以占比\n",
    "total2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.460610Z",
     "start_time": "2019-05-17T11:58:52.434606Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>营业收入</th>\n",
       "      <th>不包括折旧与摊销的营业成本</th>\n",
       "      <th>销售管理以及行政费用</th>\n",
       "      <th>折旧与摊销</th>\n",
       "      <th>资本性支出</th>\n",
       "      <th>应收账款</th>\n",
       "      <th>存货</th>\n",
       "      <th>其它流动资产合计</th>\n",
       "      <th>应付账款</th>\n",
       "      <th>其他流动负债合计</th>\n",
       "      <th>EBIT</th>\n",
       "      <th>息前税后利润</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>3.886219e+06</td>\n",
       "      <td>2.475909e+05</td>\n",
       "      <td>5.868242e+05</td>\n",
       "      <td>9.341947e+04</td>\n",
       "      <td>1.019178e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.062225e+06</td>\n",
       "      <td>6.955830e+06</td>\n",
       "      <td>1.040608e+05</td>\n",
       "      <td>3.597982e+06</td>\n",
       "      <td>2.958384e+06</td>\n",
       "      <td>2.218788e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>5.821786e+06</td>\n",
       "      <td>4.814602e+05</td>\n",
       "      <td>7.706611e+05</td>\n",
       "      <td>1.125835e+05</td>\n",
       "      <td>1.125017e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.205748e+06</td>\n",
       "      <td>9.019170e+06</td>\n",
       "      <td>9.920559e+04</td>\n",
       "      <td>3.758286e+06</td>\n",
       "      <td>4.457081e+06</td>\n",
       "      <td>3.342811e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>7.363887e+06</td>\n",
       "      <td>5.347496e+05</td>\n",
       "      <td>7.898018e+05</td>\n",
       "      <td>1.175426e+05</td>\n",
       "      <td>1.606750e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.350695e+06</td>\n",
       "      <td>1.143549e+07</td>\n",
       "      <td>1.178296e+05</td>\n",
       "      <td>4.125989e+06</td>\n",
       "      <td>5.921793e+06</td>\n",
       "      <td>4.441345e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019</th>\n",
       "      <td>1.017300e+07</td>\n",
       "      <td>7.427227e+05</td>\n",
       "      <td>1.324627e+06</td>\n",
       "      <td>2.012185e+05</td>\n",
       "      <td>2.284484e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.284622e+06</td>\n",
       "      <td>1.658876e+07</td>\n",
       "      <td>2.096187e+05</td>\n",
       "      <td>7.440526e+06</td>\n",
       "      <td>7.904435e+06</td>\n",
       "      <td>5.928326e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020</th>\n",
       "      <td>1.405372e+07</td>\n",
       "      <td>1.026051e+06</td>\n",
       "      <td>1.829935e+06</td>\n",
       "      <td>2.779777e+05</td>\n",
       "      <td>3.155951e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.919085e+06</td>\n",
       "      <td>2.291691e+07</td>\n",
       "      <td>2.895823e+05</td>\n",
       "      <td>1.027888e+07</td>\n",
       "      <td>1.091975e+07</td>\n",
       "      <td>8.189816e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021</th>\n",
       "      <td>1.941482e+07</td>\n",
       "      <td>1.417460e+06</td>\n",
       "      <td>2.528004e+06</td>\n",
       "      <td>3.840184e+05</td>\n",
       "      <td>4.359857e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>8.177049e+06</td>\n",
       "      <td>3.165906e+07</td>\n",
       "      <td>4.000498e+05</td>\n",
       "      <td>1.419998e+07</td>\n",
       "      <td>1.508533e+07</td>\n",
       "      <td>1.131400e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022</th>\n",
       "      <td>2.682102e+07</td>\n",
       "      <td>1.958181e+06</td>\n",
       "      <td>3.492366e+06</td>\n",
       "      <td>5.305107e+05</td>\n",
       "      <td>6.023020e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.129636e+07</td>\n",
       "      <td>4.373611e+07</td>\n",
       "      <td>5.526576e+05</td>\n",
       "      <td>1.961687e+07</td>\n",
       "      <td>2.083996e+07</td>\n",
       "      <td>1.562997e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023</th>\n",
       "      <td>3.705249e+07</td>\n",
       "      <td>2.705172e+06</td>\n",
       "      <td>4.824605e+06</td>\n",
       "      <td>7.328856e+05</td>\n",
       "      <td>8.320633e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.560561e+07</td>\n",
       "      <td>6.042020e+07</td>\n",
       "      <td>7.634809e+05</td>\n",
       "      <td>2.710016e+07</td>\n",
       "      <td>2.878982e+07</td>\n",
       "      <td>2.159237e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2024</th>\n",
       "      <td>5.118697e+07</td>\n",
       "      <td>3.737119e+06</td>\n",
       "      <td>6.665056e+06</td>\n",
       "      <td>1.012461e+06</td>\n",
       "      <td>1.149472e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.155871e+07</td>\n",
       "      <td>8.346881e+07</td>\n",
       "      <td>1.054727e+06</td>\n",
       "      <td>3.743811e+07</td>\n",
       "      <td>3.977233e+07</td>\n",
       "      <td>2.982925e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025</th>\n",
       "      <td>7.071336e+07</td>\n",
       "      <td>5.162725e+06</td>\n",
       "      <td>9.207588e+06</td>\n",
       "      <td>1.398686e+06</td>\n",
       "      <td>1.587963e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.978275e+07</td>\n",
       "      <td>1.153098e+08</td>\n",
       "      <td>1.457076e+06</td>\n",
       "      <td>5.171969e+07</td>\n",
       "      <td>5.494436e+07</td>\n",
       "      <td>4.120827e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2026</th>\n",
       "      <td>9.768851e+07</td>\n",
       "      <td>7.132159e+06</td>\n",
       "      <td>1.272002e+07</td>\n",
       "      <td>1.932245e+06</td>\n",
       "      <td>2.193727e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.114403e+07</td>\n",
       "      <td>1.592973e+08</td>\n",
       "      <td>2.012910e+06</td>\n",
       "      <td>7.144930e+07</td>\n",
       "      <td>7.590408e+07</td>\n",
       "      <td>5.692806e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2027</th>\n",
       "      <td>1.349539e+08</td>\n",
       "      <td>9.852877e+06</td>\n",
       "      <td>1.757235e+07</td>\n",
       "      <td>2.669343e+06</td>\n",
       "      <td>3.030572e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.683932e+07</td>\n",
       "      <td>2.200647e+08</td>\n",
       "      <td>2.780778e+06</td>\n",
       "      <td>9.870519e+07</td>\n",
       "      <td>1.048594e+08</td>\n",
       "      <td>7.864452e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2028</th>\n",
       "      <td>1.864351e+08</td>\n",
       "      <td>1.361147e+07</td>\n",
       "      <td>2.427571e+07</td>\n",
       "      <td>3.687622e+06</td>\n",
       "      <td>4.186649e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7.852193e+07</td>\n",
       "      <td>3.040132e+08</td>\n",
       "      <td>3.841567e+06</td>\n",
       "      <td>1.363584e+08</td>\n",
       "      <td>1.448603e+08</td>\n",
       "      <td>1.086452e+08</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              营业收入  不包括折旧与摊销的营业成本    销售管理以及行政费用         折旧与摊销         资本性支出  \\\n",
       "2016  3.886219e+06   2.475909e+05  5.868242e+05  9.341947e+04  1.019178e+05   \n",
       "2017  5.821786e+06   4.814602e+05  7.706611e+05  1.125835e+05  1.125017e+05   \n",
       "2018  7.363887e+06   5.347496e+05  7.898018e+05  1.175426e+05  1.606750e+05   \n",
       "2019  1.017300e+07   7.427227e+05  1.324627e+06  2.012185e+05  2.284484e+05   \n",
       "2020  1.405372e+07   1.026051e+06  1.829935e+06  2.779777e+05  3.155951e+05   \n",
       "2021  1.941482e+07   1.417460e+06  2.528004e+06  3.840184e+05  4.359857e+05   \n",
       "2022  2.682102e+07   1.958181e+06  3.492366e+06  5.305107e+05  6.023020e+05   \n",
       "2023  3.705249e+07   2.705172e+06  4.824605e+06  7.328856e+05  8.320633e+05   \n",
       "2024  5.118697e+07   3.737119e+06  6.665056e+06  1.012461e+06  1.149472e+06   \n",
       "2025  7.071336e+07   5.162725e+06  9.207588e+06  1.398686e+06  1.587963e+06   \n",
       "2026  9.768851e+07   7.132159e+06  1.272002e+07  1.932245e+06  2.193727e+06   \n",
       "2027  1.349539e+08   9.852877e+06  1.757235e+07  2.669343e+06  3.030572e+06   \n",
       "2028  1.864351e+08   1.361147e+07  2.427571e+07  3.687622e+06  4.186649e+06   \n",
       "\n",
       "      应收账款            存货      其它流动资产合计          应付账款      其他流动负债合计  \\\n",
       "2016   0.0  2.062225e+06  6.955830e+06  1.040608e+05  3.597982e+06   \n",
       "2017   0.0  2.205748e+06  9.019170e+06  9.920559e+04  3.758286e+06   \n",
       "2018   0.0  2.350695e+06  1.143549e+07  1.178296e+05  4.125989e+06   \n",
       "2019   0.0  4.284622e+06  1.658876e+07  2.096187e+05  7.440526e+06   \n",
       "2020   0.0  5.919085e+06  2.291691e+07  2.895823e+05  1.027888e+07   \n",
       "2021   0.0  8.177049e+06  3.165906e+07  4.000498e+05  1.419998e+07   \n",
       "2022   0.0  1.129636e+07  4.373611e+07  5.526576e+05  1.961687e+07   \n",
       "2023   0.0  1.560561e+07  6.042020e+07  7.634809e+05  2.710016e+07   \n",
       "2024   0.0  2.155871e+07  8.346881e+07  1.054727e+06  3.743811e+07   \n",
       "2025   0.0  2.978275e+07  1.153098e+08  1.457076e+06  5.171969e+07   \n",
       "2026   0.0  4.114403e+07  1.592973e+08  2.012910e+06  7.144930e+07   \n",
       "2027   0.0  5.683932e+07  2.200647e+08  2.780778e+06  9.870519e+07   \n",
       "2028   0.0  7.852193e+07  3.040132e+08  3.841567e+06  1.363584e+08   \n",
       "\n",
       "              EBIT        息前税后利润  \n",
       "2016  2.958384e+06  2.218788e+06  \n",
       "2017  4.457081e+06  3.342811e+06  \n",
       "2018  5.921793e+06  4.441345e+06  \n",
       "2019  7.904435e+06  5.928326e+06  \n",
       "2020  1.091975e+07  8.189816e+06  \n",
       "2021  1.508533e+07  1.131400e+07  \n",
       "2022  2.083996e+07  1.562997e+07  \n",
       "2023  2.878982e+07  2.159237e+07  \n",
       "2024  3.977233e+07  2.982925e+07  \n",
       "2025  5.494436e+07  4.120827e+07  \n",
       "2026  7.590408e+07  5.692806e+07  \n",
       "2027  1.048594e+08  7.864452e+07  \n",
       "2028  1.448603e+08  1.086452e+08  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "total2['EBIT']=total2['营业收入']-total2['不包括折旧与摊销的营业成本']-total2['销售管理以及行政费用']-total2['折旧与摊销']\n",
    "total2['息前税后利润']=total2['EBIT']*(1-Tax)\n",
    "total2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.509612Z",
     "start_time": "2019-05-17T11:58:52.464608Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>营业收入</th>\n",
       "      <th>不包括折旧与摊销的营业成本</th>\n",
       "      <th>销售管理以及行政费用</th>\n",
       "      <th>折旧与摊销</th>\n",
       "      <th>资本性支出</th>\n",
       "      <th>应收账款</th>\n",
       "      <th>存货</th>\n",
       "      <th>其它流动资产合计</th>\n",
       "      <th>应付账款</th>\n",
       "      <th>其他流动负债合计</th>\n",
       "      <th>EBIT</th>\n",
       "      <th>息前税后利润</th>\n",
       "      <th>营运资本</th>\n",
       "      <th>营运资本增加额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>3.886219e+06</td>\n",
       "      <td>2.475909e+05</td>\n",
       "      <td>5.868242e+05</td>\n",
       "      <td>9.341947e+04</td>\n",
       "      <td>1.019178e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.062225e+06</td>\n",
       "      <td>6.955830e+06</td>\n",
       "      <td>1.040608e+05</td>\n",
       "      <td>3.597982e+06</td>\n",
       "      <td>2.958384e+06</td>\n",
       "      <td>2.218788e+06</td>\n",
       "      <td>5.316012e+06</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>5.821786e+06</td>\n",
       "      <td>4.814602e+05</td>\n",
       "      <td>7.706611e+05</td>\n",
       "      <td>1.125835e+05</td>\n",
       "      <td>1.125017e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.205748e+06</td>\n",
       "      <td>9.019170e+06</td>\n",
       "      <td>9.920559e+04</td>\n",
       "      <td>3.758286e+06</td>\n",
       "      <td>4.457081e+06</td>\n",
       "      <td>3.342811e+06</td>\n",
       "      <td>7.367427e+06</td>\n",
       "      <td>2.051414e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>7.363887e+06</td>\n",
       "      <td>5.347496e+05</td>\n",
       "      <td>7.898018e+05</td>\n",
       "      <td>1.175426e+05</td>\n",
       "      <td>1.606750e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.350695e+06</td>\n",
       "      <td>1.143549e+07</td>\n",
       "      <td>1.178296e+05</td>\n",
       "      <td>4.125989e+06</td>\n",
       "      <td>5.921793e+06</td>\n",
       "      <td>4.441345e+06</td>\n",
       "      <td>9.542365e+06</td>\n",
       "      <td>2.174938e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019</th>\n",
       "      <td>1.017300e+07</td>\n",
       "      <td>7.427227e+05</td>\n",
       "      <td>1.324627e+06</td>\n",
       "      <td>2.012185e+05</td>\n",
       "      <td>2.284484e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.284622e+06</td>\n",
       "      <td>1.658876e+07</td>\n",
       "      <td>2.096187e+05</td>\n",
       "      <td>7.440526e+06</td>\n",
       "      <td>7.904435e+06</td>\n",
       "      <td>5.928326e+06</td>\n",
       "      <td>1.322324e+07</td>\n",
       "      <td>3.680875e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020</th>\n",
       "      <td>1.405372e+07</td>\n",
       "      <td>1.026051e+06</td>\n",
       "      <td>1.829935e+06</td>\n",
       "      <td>2.779777e+05</td>\n",
       "      <td>3.155951e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.919085e+06</td>\n",
       "      <td>2.291691e+07</td>\n",
       "      <td>2.895823e+05</td>\n",
       "      <td>1.027888e+07</td>\n",
       "      <td>1.091975e+07</td>\n",
       "      <td>8.189816e+06</td>\n",
       "      <td>1.826753e+07</td>\n",
       "      <td>5.044294e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021</th>\n",
       "      <td>1.941482e+07</td>\n",
       "      <td>1.417460e+06</td>\n",
       "      <td>2.528004e+06</td>\n",
       "      <td>3.840184e+05</td>\n",
       "      <td>4.359857e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>8.177049e+06</td>\n",
       "      <td>3.165906e+07</td>\n",
       "      <td>4.000498e+05</td>\n",
       "      <td>1.419998e+07</td>\n",
       "      <td>1.508533e+07</td>\n",
       "      <td>1.131400e+07</td>\n",
       "      <td>2.523608e+07</td>\n",
       "      <td>6.968550e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022</th>\n",
       "      <td>2.682102e+07</td>\n",
       "      <td>1.958181e+06</td>\n",
       "      <td>3.492366e+06</td>\n",
       "      <td>5.305107e+05</td>\n",
       "      <td>6.023020e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.129636e+07</td>\n",
       "      <td>4.373611e+07</td>\n",
       "      <td>5.526576e+05</td>\n",
       "      <td>1.961687e+07</td>\n",
       "      <td>2.083996e+07</td>\n",
       "      <td>1.562997e+07</td>\n",
       "      <td>3.486294e+07</td>\n",
       "      <td>9.626856e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023</th>\n",
       "      <td>3.705249e+07</td>\n",
       "      <td>2.705172e+06</td>\n",
       "      <td>4.824605e+06</td>\n",
       "      <td>7.328856e+05</td>\n",
       "      <td>8.320633e+05</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.560561e+07</td>\n",
       "      <td>6.042020e+07</td>\n",
       "      <td>7.634809e+05</td>\n",
       "      <td>2.710016e+07</td>\n",
       "      <td>2.878982e+07</td>\n",
       "      <td>2.159237e+07</td>\n",
       "      <td>4.816217e+07</td>\n",
       "      <td>1.329923e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2024</th>\n",
       "      <td>5.118697e+07</td>\n",
       "      <td>3.737119e+06</td>\n",
       "      <td>6.665056e+06</td>\n",
       "      <td>1.012461e+06</td>\n",
       "      <td>1.149472e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.155871e+07</td>\n",
       "      <td>8.346881e+07</td>\n",
       "      <td>1.054727e+06</td>\n",
       "      <td>3.743811e+07</td>\n",
       "      <td>3.977233e+07</td>\n",
       "      <td>2.982925e+07</td>\n",
       "      <td>6.653468e+07</td>\n",
       "      <td>1.837251e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025</th>\n",
       "      <td>7.071336e+07</td>\n",
       "      <td>5.162725e+06</td>\n",
       "      <td>9.207588e+06</td>\n",
       "      <td>1.398686e+06</td>\n",
       "      <td>1.587963e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2.978275e+07</td>\n",
       "      <td>1.153098e+08</td>\n",
       "      <td>1.457076e+06</td>\n",
       "      <td>5.171969e+07</td>\n",
       "      <td>5.494436e+07</td>\n",
       "      <td>4.120827e+07</td>\n",
       "      <td>9.191579e+07</td>\n",
       "      <td>2.538111e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2026</th>\n",
       "      <td>9.768851e+07</td>\n",
       "      <td>7.132159e+06</td>\n",
       "      <td>1.272002e+07</td>\n",
       "      <td>1.932245e+06</td>\n",
       "      <td>2.193727e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.114403e+07</td>\n",
       "      <td>1.592973e+08</td>\n",
       "      <td>2.012910e+06</td>\n",
       "      <td>7.144930e+07</td>\n",
       "      <td>7.590408e+07</td>\n",
       "      <td>5.692806e+07</td>\n",
       "      <td>1.269791e+08</td>\n",
       "      <td>3.506329e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2027</th>\n",
       "      <td>1.349539e+08</td>\n",
       "      <td>9.852877e+06</td>\n",
       "      <td>1.757235e+07</td>\n",
       "      <td>2.669343e+06</td>\n",
       "      <td>3.030572e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.683932e+07</td>\n",
       "      <td>2.200647e+08</td>\n",
       "      <td>2.780778e+06</td>\n",
       "      <td>9.870519e+07</td>\n",
       "      <td>1.048594e+08</td>\n",
       "      <td>7.864452e+07</td>\n",
       "      <td>1.754180e+08</td>\n",
       "      <td>4.843895e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2028</th>\n",
       "      <td>1.864351e+08</td>\n",
       "      <td>1.361147e+07</td>\n",
       "      <td>2.427571e+07</td>\n",
       "      <td>3.687622e+06</td>\n",
       "      <td>4.186649e+06</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7.852193e+07</td>\n",
       "      <td>3.040132e+08</td>\n",
       "      <td>3.841567e+06</td>\n",
       "      <td>1.363584e+08</td>\n",
       "      <td>1.448603e+08</td>\n",
       "      <td>1.086452e+08</td>\n",
       "      <td>2.423351e+08</td>\n",
       "      <td>6.691704e+07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              营业收入  不包括折旧与摊销的营业成本    销售管理以及行政费用         折旧与摊销         资本性支出  \\\n",
       "2016  3.886219e+06   2.475909e+05  5.868242e+05  9.341947e+04  1.019178e+05   \n",
       "2017  5.821786e+06   4.814602e+05  7.706611e+05  1.125835e+05  1.125017e+05   \n",
       "2018  7.363887e+06   5.347496e+05  7.898018e+05  1.175426e+05  1.606750e+05   \n",
       "2019  1.017300e+07   7.427227e+05  1.324627e+06  2.012185e+05  2.284484e+05   \n",
       "2020  1.405372e+07   1.026051e+06  1.829935e+06  2.779777e+05  3.155951e+05   \n",
       "2021  1.941482e+07   1.417460e+06  2.528004e+06  3.840184e+05  4.359857e+05   \n",
       "2022  2.682102e+07   1.958181e+06  3.492366e+06  5.305107e+05  6.023020e+05   \n",
       "2023  3.705249e+07   2.705172e+06  4.824605e+06  7.328856e+05  8.320633e+05   \n",
       "2024  5.118697e+07   3.737119e+06  6.665056e+06  1.012461e+06  1.149472e+06   \n",
       "2025  7.071336e+07   5.162725e+06  9.207588e+06  1.398686e+06  1.587963e+06   \n",
       "2026  9.768851e+07   7.132159e+06  1.272002e+07  1.932245e+06  2.193727e+06   \n",
       "2027  1.349539e+08   9.852877e+06  1.757235e+07  2.669343e+06  3.030572e+06   \n",
       "2028  1.864351e+08   1.361147e+07  2.427571e+07  3.687622e+06  4.186649e+06   \n",
       "\n",
       "      应收账款            存货      其它流动资产合计          应付账款      其他流动负债合计  \\\n",
       "2016   0.0  2.062225e+06  6.955830e+06  1.040608e+05  3.597982e+06   \n",
       "2017   0.0  2.205748e+06  9.019170e+06  9.920559e+04  3.758286e+06   \n",
       "2018   0.0  2.350695e+06  1.143549e+07  1.178296e+05  4.125989e+06   \n",
       "2019   0.0  4.284622e+06  1.658876e+07  2.096187e+05  7.440526e+06   \n",
       "2020   0.0  5.919085e+06  2.291691e+07  2.895823e+05  1.027888e+07   \n",
       "2021   0.0  8.177049e+06  3.165906e+07  4.000498e+05  1.419998e+07   \n",
       "2022   0.0  1.129636e+07  4.373611e+07  5.526576e+05  1.961687e+07   \n",
       "2023   0.0  1.560561e+07  6.042020e+07  7.634809e+05  2.710016e+07   \n",
       "2024   0.0  2.155871e+07  8.346881e+07  1.054727e+06  3.743811e+07   \n",
       "2025   0.0  2.978275e+07  1.153098e+08  1.457076e+06  5.171969e+07   \n",
       "2026   0.0  4.114403e+07  1.592973e+08  2.012910e+06  7.144930e+07   \n",
       "2027   0.0  5.683932e+07  2.200647e+08  2.780778e+06  9.870519e+07   \n",
       "2028   0.0  7.852193e+07  3.040132e+08  3.841567e+06  1.363584e+08   \n",
       "\n",
       "              EBIT        息前税后利润          营运资本       营运资本增加额  \n",
       "2016  2.958384e+06  2.218788e+06  5.316012e+06           NaN  \n",
       "2017  4.457081e+06  3.342811e+06  7.367427e+06  2.051414e+06  \n",
       "2018  5.921793e+06  4.441345e+06  9.542365e+06  2.174938e+06  \n",
       "2019  7.904435e+06  5.928326e+06  1.322324e+07  3.680875e+06  \n",
       "2020  1.091975e+07  8.189816e+06  1.826753e+07  5.044294e+06  \n",
       "2021  1.508533e+07  1.131400e+07  2.523608e+07  6.968550e+06  \n",
       "2022  2.083996e+07  1.562997e+07  3.486294e+07  9.626856e+06  \n",
       "2023  2.878982e+07  2.159237e+07  4.816217e+07  1.329923e+07  \n",
       "2024  3.977233e+07  2.982925e+07  6.653468e+07  1.837251e+07  \n",
       "2025  5.494436e+07  4.120827e+07  9.191579e+07  2.538111e+07  \n",
       "2026  7.590408e+07  5.692806e+07  1.269791e+08  3.506329e+07  \n",
       "2027  1.048594e+08  7.864452e+07  1.754180e+08  4.843895e+07  \n",
       "2028  1.448603e+08  1.086452e+08  2.423351e+08  6.691704e+07  "
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "total2['营运资本']=total2['应收账款']+total2['存货']+total2['其它流动资产合计']-total2['其他流动负债合计']-total2['应付账款']\n",
    "total2['营运资本增加额']=total2['营运资本']-total2['营运资本'].shift(1)#下一行减去上一行的值\n",
    "total2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.544614Z",
     "start_time": "2019-05-17T11:58:52.511611Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>息前税后利润</th>\n",
       "      <th>折旧与摊销</th>\n",
       "      <th>资本性支出</th>\n",
       "      <th>营运资本增加额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>2.218788e+06</td>\n",
       "      <td>9.341947e+04</td>\n",
       "      <td>1.019178e+05</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>3.342811e+06</td>\n",
       "      <td>1.125835e+05</td>\n",
       "      <td>1.125017e+05</td>\n",
       "      <td>2.051414e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>4.441345e+06</td>\n",
       "      <td>1.175426e+05</td>\n",
       "      <td>1.606750e+05</td>\n",
       "      <td>2.174938e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019</th>\n",
       "      <td>5.928326e+06</td>\n",
       "      <td>2.012185e+05</td>\n",
       "      <td>2.284484e+05</td>\n",
       "      <td>3.680875e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020</th>\n",
       "      <td>8.189816e+06</td>\n",
       "      <td>2.779777e+05</td>\n",
       "      <td>3.155951e+05</td>\n",
       "      <td>5.044294e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021</th>\n",
       "      <td>1.131400e+07</td>\n",
       "      <td>3.840184e+05</td>\n",
       "      <td>4.359857e+05</td>\n",
       "      <td>6.968550e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022</th>\n",
       "      <td>1.562997e+07</td>\n",
       "      <td>5.305107e+05</td>\n",
       "      <td>6.023020e+05</td>\n",
       "      <td>9.626856e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023</th>\n",
       "      <td>2.159237e+07</td>\n",
       "      <td>7.328856e+05</td>\n",
       "      <td>8.320633e+05</td>\n",
       "      <td>1.329923e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2024</th>\n",
       "      <td>2.982925e+07</td>\n",
       "      <td>1.012461e+06</td>\n",
       "      <td>1.149472e+06</td>\n",
       "      <td>1.837251e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025</th>\n",
       "      <td>4.120827e+07</td>\n",
       "      <td>1.398686e+06</td>\n",
       "      <td>1.587963e+06</td>\n",
       "      <td>2.538111e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2026</th>\n",
       "      <td>5.692806e+07</td>\n",
       "      <td>1.932245e+06</td>\n",
       "      <td>2.193727e+06</td>\n",
       "      <td>3.506329e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2027</th>\n",
       "      <td>7.864452e+07</td>\n",
       "      <td>2.669343e+06</td>\n",
       "      <td>3.030572e+06</td>\n",
       "      <td>4.843895e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2028</th>\n",
       "      <td>1.086452e+08</td>\n",
       "      <td>3.687622e+06</td>\n",
       "      <td>4.186649e+06</td>\n",
       "      <td>6.691704e+07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            息前税后利润         折旧与摊销         资本性支出       营运资本增加额\n",
       "2016  2.218788e+06  9.341947e+04  1.019178e+05           NaN\n",
       "2017  3.342811e+06  1.125835e+05  1.125017e+05  2.051414e+06\n",
       "2018  4.441345e+06  1.175426e+05  1.606750e+05  2.174938e+06\n",
       "2019  5.928326e+06  2.012185e+05  2.284484e+05  3.680875e+06\n",
       "2020  8.189816e+06  2.779777e+05  3.155951e+05  5.044294e+06\n",
       "2021  1.131400e+07  3.840184e+05  4.359857e+05  6.968550e+06\n",
       "2022  1.562997e+07  5.305107e+05  6.023020e+05  9.626856e+06\n",
       "2023  2.159237e+07  7.328856e+05  8.320633e+05  1.329923e+07\n",
       "2024  2.982925e+07  1.012461e+06  1.149472e+06  1.837251e+07\n",
       "2025  4.120827e+07  1.398686e+06  1.587963e+06  2.538111e+07\n",
       "2026  5.692806e+07  1.932245e+06  2.193727e+06  3.506329e+07\n",
       "2027  7.864452e+07  2.669343e+06  3.030572e+06  4.843895e+07\n",
       "2028  1.086452e+08  3.687622e+06  4.186649e+06  6.691704e+07"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "total3=total2.loc[:,['息前税后利润','折旧与摊销','资本性支出','营运资本增加额']]\n",
    "total3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.582616Z",
     "start_time": "2019-05-17T11:58:52.552616Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>息前税后利润</th>\n",
       "      <th>折旧与摊销</th>\n",
       "      <th>资本性支出</th>\n",
       "      <th>营运资本增加额</th>\n",
       "      <th>实体现金流量</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2016</th>\n",
       "      <td>2.218788e+06</td>\n",
       "      <td>9.341947e+04</td>\n",
       "      <td>1.019178e+05</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017</th>\n",
       "      <td>3.342811e+06</td>\n",
       "      <td>1.125835e+05</td>\n",
       "      <td>1.125017e+05</td>\n",
       "      <td>2.051414e+06</td>\n",
       "      <td>1.291478e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018</th>\n",
       "      <td>4.441345e+06</td>\n",
       "      <td>1.175426e+05</td>\n",
       "      <td>1.606750e+05</td>\n",
       "      <td>2.174938e+06</td>\n",
       "      <td>2.223274e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019</th>\n",
       "      <td>5.928326e+06</td>\n",
       "      <td>2.012185e+05</td>\n",
       "      <td>2.284484e+05</td>\n",
       "      <td>3.680875e+06</td>\n",
       "      <td>2.220221e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020</th>\n",
       "      <td>8.189816e+06</td>\n",
       "      <td>2.779777e+05</td>\n",
       "      <td>3.155951e+05</td>\n",
       "      <td>5.044294e+06</td>\n",
       "      <td>3.107905e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021</th>\n",
       "      <td>1.131400e+07</td>\n",
       "      <td>3.840184e+05</td>\n",
       "      <td>4.359857e+05</td>\n",
       "      <td>6.968550e+06</td>\n",
       "      <td>4.293483e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2022</th>\n",
       "      <td>1.562997e+07</td>\n",
       "      <td>5.305107e+05</td>\n",
       "      <td>6.023020e+05</td>\n",
       "      <td>9.626856e+06</td>\n",
       "      <td>5.931326e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2023</th>\n",
       "      <td>2.159237e+07</td>\n",
       "      <td>7.328856e+05</td>\n",
       "      <td>8.320633e+05</td>\n",
       "      <td>1.329923e+07</td>\n",
       "      <td>8.193959e+06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2024</th>\n",
       "      <td>2.982925e+07</td>\n",
       "      <td>1.012461e+06</td>\n",
       "      <td>1.149472e+06</td>\n",
       "      <td>1.837251e+07</td>\n",
       "      <td>1.131972e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2025</th>\n",
       "      <td>4.120827e+07</td>\n",
       "      <td>1.398686e+06</td>\n",
       "      <td>1.587963e+06</td>\n",
       "      <td>2.538111e+07</td>\n",
       "      <td>1.563788e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2026</th>\n",
       "      <td>5.692806e+07</td>\n",
       "      <td>1.932245e+06</td>\n",
       "      <td>2.193727e+06</td>\n",
       "      <td>3.506329e+07</td>\n",
       "      <td>2.160329e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2027</th>\n",
       "      <td>7.864452e+07</td>\n",
       "      <td>2.669343e+06</td>\n",
       "      <td>3.030572e+06</td>\n",
       "      <td>4.843895e+07</td>\n",
       "      <td>2.984434e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2028</th>\n",
       "      <td>1.086452e+08</td>\n",
       "      <td>3.687622e+06</td>\n",
       "      <td>4.186649e+06</td>\n",
       "      <td>6.691704e+07</td>\n",
       "      <td>4.122912e+07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            息前税后利润         折旧与摊销         资本性支出       营运资本增加额        实体现金流量\n",
       "2016  2.218788e+06  9.341947e+04  1.019178e+05           NaN           NaN\n",
       "2017  3.342811e+06  1.125835e+05  1.125017e+05  2.051414e+06  1.291478e+06\n",
       "2018  4.441345e+06  1.175426e+05  1.606750e+05  2.174938e+06  2.223274e+06\n",
       "2019  5.928326e+06  2.012185e+05  2.284484e+05  3.680875e+06  2.220221e+06\n",
       "2020  8.189816e+06  2.779777e+05  3.155951e+05  5.044294e+06  3.107905e+06\n",
       "2021  1.131400e+07  3.840184e+05  4.359857e+05  6.968550e+06  4.293483e+06\n",
       "2022  1.562997e+07  5.305107e+05  6.023020e+05  9.626856e+06  5.931326e+06\n",
       "2023  2.159237e+07  7.328856e+05  8.320633e+05  1.329923e+07  8.193959e+06\n",
       "2024  2.982925e+07  1.012461e+06  1.149472e+06  1.837251e+07  1.131972e+07\n",
       "2025  4.120827e+07  1.398686e+06  1.587963e+06  2.538111e+07  1.563788e+07\n",
       "2026  5.692806e+07  1.932245e+06  2.193727e+06  3.506329e+07  2.160329e+07\n",
       "2027  7.864452e+07  2.669343e+06  3.030572e+06  4.843895e+07  2.984434e+07\n",
       "2028  1.086452e+08  3.687622e+06  4.186649e+06  6.691704e+07  4.122912e+07"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "total3['实体现金流量']=total3['息前税后利润']+total3['折旧与摊销']-total3['资本性支出']-total3['营运资本增加额']\n",
    "total3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:44:25.899514Z",
     "start_time": "2019-05-17T11:44:25.862514Z"
    }
   },
   "outputs": [],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-14T06:47:04.723212Z",
     "start_time": "2019-05-14T06:47:04.491159Z"
    }
   },
   "source": [
    "无风险利率，这里使用同到期期限的国债到期收益率。这里数据我们主要从和讯财经网上获取。\n",
    "\n",
    "使用以下程序来获取无风险利率，由于每一年1月1日均为节假期，没有数据，为了避免出现空缺值，我们使用1月4日的国债到期收益率曲线，获取到期期限为一年到期收益率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-17T11:58:52.740646Z",
     "start_time": "2019-05-17T11:58:52.584616Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.5968"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#获取无风险利率，由于每一年1月1日均为节假期，没有数据，为了避免出现空缺值，我们使用1月4日的国债到期收益率曲线，\n",
    "#并主要获取到期期限为一年的数据\n",
    "def RF(year):\n",
    "    date=str(year)+'-01-04'\n",
    "    Rfurl='http://bond.money.hexun.com/data/js/data/trans.aspx?date='+str(year)+'-01-04&count=19&titType=null&page=1'\n",
    "    from_data={'date':date,\n",
    "           'count':'19',\n",
    "           'titType':'null','page':'1'}\n",
    "    header1={'Host':'bond.money.hexun.com',\n",
    "         'Referer':'http://bond.money.hexun.com/data/yield.aspx',\n",
    "         'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) \\\n",
    "         AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0'}\n",
    "    response1=requests.get(Rfurl,headers=header1,data=from_data)\n",
    "    re2=response1.text\n",
    "    re3=re.findall(\"standardDeadline:'1y',yield:'(.*?)'}\",re2)\n",
    "    Rf=float(re3[0])\n",
    "    return Rf\n",
    "RF(year)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-16T08:14:35.701406Z",
     "start_time": "2019-05-16T08:14:35.693389Z"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-05-14T02:59:16.659450Z",
     "start_time": "2019-05-14T02:59:16.632466Z"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
